//
//  NSObject+BLTip.m
//  BasketBallLeagues
//
//  Created by kenshin on 4/23/17.
//  Copyright © 2017 kenshin. All rights reserved.
//

#import "NSObject+KSTip.h"

#import <SVProgressHUD.h>
#import <MBProgressHUD.h>

@implementation NSObject (KSTip)

- (void)ks_showProgress
{
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
    [SVProgressHUD setBackgroundColor:[[UIColor blackColor] colorWithAlphaComponent:0.6]];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeNone];
    [SVProgressHUD setDefaultAnimationType:SVProgressHUDAnimationTypeNative];
    [SVProgressHUD show];
}

- (void)ks_hideProgress
{
    [SVProgressHUD dismiss];
}

- (void)ks_showToast:(NSString *)toast
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[self keyWindow] animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.label.text = toast;
    hud.animationType = MBProgressHUDAnimationZoomOut;
    hud.removeFromSuperViewOnHide = YES;
    [hud hideAnimated:YES afterDelay:1];
}

- (void)ks_showLongToast:(NSString *)longToast
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[self keyWindow] animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.detailsLabel.text = longToast;
    hud.animationType = MBProgressHUDAnimationZoomOut;
    hud.removeFromSuperViewOnHide = YES;
    [hud hideAnimated:YES afterDelay:2];
}

- (UIWindow *)keyWindow
{
    return [UIApplication sharedApplication].delegate.window;
}

@end
